<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Array</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Array</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/plugins/to_xls/lib/to_xls_rb.html">
                vendor/plugins/to_xls/lib/to_xls.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000001">to_xls</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000001" class="method-detail">
        <a name="M000001"></a>

        <div class="method-heading">
          <a href="#M000001" class="method-signature">
          <span class="method-name">to_xls</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000001-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/to_xls/lib/to_xls.rb, line 3</span>
 3:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_xls</span>(<span class="ruby-identifier">options</span> = {})
 4:     <span class="ruby-identifier">output</span> = <span class="ruby-value str">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;Workbook xmlns:x=&quot;urn:schemas-microsoft-com:office:excel&quot; xmlns:ss=&quot;urn:schemas-microsoft-com:office:spreadsheet&quot; xmlns:html=&quot;http://www.w3.org/TR/REC-html40&quot; xmlns=&quot;urn:schemas-microsoft-com:office:spreadsheet&quot; xmlns:o=&quot;urn:schemas-microsoft-com:office:office&quot;&gt;&lt;Worksheet ss:Name=&quot;Sheet1&quot;&gt;&lt;Table&gt;'</span>
 5:     
 6:     <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">any?</span>
 7:     
 8:       <span class="ruby-identifier">attributes</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">attributes</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">c</span><span class="ruby-operator">|</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">to_sym</span> }
 9:       
10:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>]
11:         <span class="ruby-comment cmt"># the &quot;&amp; attributes&quot; get rid of invalid columns</span>
12:         <span class="ruby-identifier">columns</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>].<span class="ruby-identifier">to_a</span> <span class="ruby-operator">&amp;</span> <span class="ruby-identifier">attributes</span>
13:       <span class="ruby-keyword kw">else</span>
14:         <span class="ruby-identifier">columns</span> = <span class="ruby-identifier">attributes</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>].<span class="ruby-identifier">to_a</span>
15:       <span class="ruby-keyword kw">end</span>
16:     
17:       <span class="ruby-identifier">columns</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:methods</span>].<span class="ruby-identifier">to_a</span>
18:     
19:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">columns</span>.<span class="ruby-identifier">any?</span>
20:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:headers</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span>
21:           <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Row&gt;&quot;</span>
22:           <span class="ruby-identifier">columns</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">column</span><span class="ruby-operator">|</span> 
23:                         <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;Cell&gt;&lt;Data ss:Type=\&quot;String\&quot;&gt;#{column}&lt;/Data&gt;&lt;/Cell&gt;&quot;</span> 
24:                   }
25:           <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Row&gt;&quot;</span>
26:         <span class="ruby-keyword kw">end</span>    
27: 
28:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span>
29:           <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;Row&gt;&quot;</span>
30:           
31:           <span class="ruby-identifier">columns</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">column</span><span class="ruby-operator">|</span> 
32:                     <span class="ruby-identifier">item</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">column</span>).<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:to_s_br</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">cell</span> = <span class="ruby-identifier">item</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">column</span>).<span class="ruby-identifier">to_s_br</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">cell</span> = <span class="ruby-identifier">item</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">column</span>)
33:                         <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;&lt;Cell&gt;&lt;Data ss:Type=\&quot;#{item.send(column).kind_of?(Integer) ? 'Number' : 'String'}\&quot;&gt;#{cell}&lt;/Data&gt;&lt;/Cell&gt;&quot;</span> 
34:                   }
35:                   
36:           <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&lt;/Row&gt;&quot;</span>
37:         <span class="ruby-keyword kw">end</span>
38:       <span class="ruby-keyword kw">end</span>
39:       
40:     <span class="ruby-keyword kw">end</span>
41:     
42:     <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">'&lt;/Table&gt;&lt;/Worksheet&gt;&lt;/Workbook&gt;'</span>
43:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>